<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./css/login.css">
    <link rel="stylesheet" href="./css/sx.css.css">
    <link rel="stylesheet" href="./login-iconfont/iconfont.css">
    <script src="./api/axios.js"></script>
    <style>
        header{
            background: 0 0 repeat-y url(./img/bj2.png);
            background-size: cover;
            height: 920px;
            background-repeat: no-repeat;
            position: relative;
}
    </style>
</head>
<body>
    <header>
        <main id="main">
            <div class="ye">
                 <h2>密码登录</h2>
                 <h2 id="duan">短信登录</h2>
            </div>
            <div class="input">
                 <input type="text" placeholder="账号名/邮箱/手机号">
        <input type="password" placeholder="请输入登录密码">
        <input type="button" value="登录" id="bnt">
            </div>
       
            </div>
            <div class="wang">
             <p>忘记密码</p>
             <p>忘记用户名</p>
             <p id="zc">免费注册</p>
            </div>
            <div class="sao">
                 <i>扫码登录更安全</i>
                 <span></span>
            </div>
           <div class="iconfont icon-bg-qrCode">

           </div>
           
       
        </main>
         <div class="pos" id="posi">
            <div class="ye">
                <h2 id="mi">密码登录</h2>
                <h2>短信登录</h2>
           </div>
           <div class="input">
                <input type="text" placeholder="请输入手机号">
       <input type="password" placeholder="请输入验证码">
       <input type="button" value="登录">
           </div>
      
           </div>
     
      
           </div>
      
          
            </div>
    </header>
</body>
<script>
    let main=document.getElementById('main')
    let pos=document.getElementById('posi')
    let duan=document.getElementById('duan')
    let mi=document.getElementById('mi')
    let zc=document.getElementById('zc')
    let oinput=document.querySelectorAll('input')
    console.log(oinput)
    console.log(main,pos)
    duan.onclick=function(){
        main.style.display='none'
        pos.style.display='block'
    }
    mi.onclick=function(){
        pos.style.display='none'
        main.style.display='block'
    }
    zc.onclick=function(){
        location.href='register.html'
    }
    oinput[2].onclick=function(){
     axios.get('http://jx.xuzhixiang.top/ap/api/login.php',{
         params:{
            'username':oinput[0].value,
            'password':oinput[1].value
         }
     }).then( res=>{
         console.log(res,'66666')
         let data=res.data;
         
         if(data.code==1){
             window.localStorage.setItem('uid',data.data.id)
             location.href='index.html'
            let a = localStorage.setItem('userData',JSON.stringify(data))
         }else{
             alert('密码或账号错误，请重新输入')
         }
     })
    }
</script>
</html>